package edu.njust.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.sql.Date;
import java.util.List;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class LabReservation extends Reservation{
    private Date begin_date;//TODO
    private Date end_date;//TODO
    private Integer plan_num;
    private Integer remain_num;

    //TODO
    public LabReservation(String user_id, String name, Integer type, Date begin_date, Date end_date, Integer plan_num, Integer remain_num){
        super(user_id, name, type);
        this.begin_date = begin_date;
        this.end_date = end_date;
        this.plan_num = plan_num;
        this.remain_num = remain_num;
    }

    public Integer select(){
        if(plan_num > remain_num){
            remain_num++;
            return 1;
        }
        return 0;
    }

    public Integer quit(){
        if(remain_num>0){
            remain_num--;
            return 1;
        }
        return 0;
    }

    public Reservation toReservation(){
        Reservation reservation = new Reservation(this.getId(), this.getUser_id(), this.getName(), this.getState(), 3);
        return reservation;
    }
}
